package yyy.ab.modules.generator.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import yyy.ab.common.core.ResultBean;
import yyy.ab.modules.generator.entity.GenConfig;
import yyy.ab.modules.generator.service.GenConfigService;

/**
 * @author Zheng Jie
 * @date 2019-01-14
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/code/genConfig")
@Api(tags = "系统：代码生成器配置管理")
public class GenConfigController {

    private final GenConfigService genConfigService;

    @ApiOperation("查询")
    @GetMapping(value = "/{tableName}")
    public Object query(@PathVariable String tableName){
        return genConfigService.find(tableName);
    }

    @ApiOperation("修改")
    @PutMapping
    public Object update(@RequestBody GenConfig genConfig){
        return ResultBean.success(genConfigService.update(genConfig.getTableName(), genConfig));
    }
}
